//
// Created by xili on 2024/8/13 21:14.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int kthFactor(int n, int k) {
        vector<int> ans;
        for (int i = 1; i <= n; i++) {
            if (n % i == 0) {
                ans.push_back(i);
            }
        }
        int size = ans.size();
        return size < k ? -1 : ans[k - 1];
    }
};